<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<script type="text/javascript">
	$(function() {
		$("#visibility").get(0).selectedIndex=${blog.visibility-1 };
		$("#classname").get(0).selectedIndex=${blog.classname-1 };
		//$("#isForward").attr("checked",${blog.isForward});
	});
	//初始化xheditor
	$(function() {
		$("#content").xheditor({
			tools : 'Removeformat,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,Align,Emot,Img',
			skin : 'default',
			showBlocktag : false,//段落标签
			internalScript : false,
			internalStyle : false,
			width : 590,
			height : 368,
			fullscreen : false,
			forcePtag : true,
			upMultiple:1,
			html5Upload:false,
			upImgUrl : "xhUploadImage.htm",
			upImgExt:'jpg,jpeg,gif,png',
			onUpload:insertUpload//指定回调函数
		});
		$("#content").focus();
	});
	
	function editBlog(id) {
		var content = $("#content").val();
		$.ajax({
			type : "POST",
			url : "editBlog.htm",
			data : {
				'identifier' : id,
				'content' : content,
				'subject' : $("#subject").val(),
				'classname' : $("#classname ").val(),
				'password' : $("#blogPwd").val(),
				'visibility':$("#visibility").val(),
				'isForward':$("#isForward").attr("checked")
			},
			success : function() {
				$("#content").xheditor(false);
				$("#content_detail").load("enterBlog.htm?&operationType=editSuccess");
			}
		});
	}
	//编辑图片上传回调函数
	function insertUpload(msg){
		$("#preImg").html("图片预览：<img width='200' height='150' src='"+msg+"'/>")
		var _msg=msg.toString();
		$("#content").append(_msg);
	}
	//处理服务器返回到回调函数的字符串内容,格式是JSON的数据格式.
	function Substring(s){
		return s.substring(s.substring(0,s.lastIndexOf("/")).lastIndexOf("/"),s.length);
	}
</script>

	<div id="divEditBlog">
		<div class="h_editBox">
			<input type="hidden" name="identifier" value="${blog.identifier }" />
			<table>
				<tr>
					<td width="59" class="h_edit_text">标题:</td>
					<td width="679"><input class="h_edit_title" type="text"
						id="subject" name="subject" value="${blog.subject}" /> <a
						href="javascript:void(0);" onclick="showDeleteDiv(${blog.identifier });">删 除</a>
					</td>
				</tr>
				<tr>
					<td class="h_edit_text">内容:</td>
					<td><textarea id="content" rows="10" cols="16" name="content">${blog.blogContent.content}</textarea>
					</td>

				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>分类：<select id="classname">
							<c:forEach items="${cList}" var="blogClassname">
								<option value="${blogClassname.value }">${blogClassname.label}</option>
							</c:forEach>
					</select> <%--<a href="#">[分类管理]</a> --%>
					</td>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>权限： <select id="visibility">
							<c:forEach items="${vList}" var="blogVisibility">
								<option value="${blogVisibility.value }">${blogVisibility.label}</option>
							</c:forEach>
					</select> <%-- <input id="isForward" type="checkbox" value="" />允许好友转帖</td>--%>
				</tr>
				<tr>
					<td>&nbsp;</td>
					<td>
						<div class="h_button fl mr5"
							onclick="editBlog(${blog.identifier });">
							<strong>发 表</strong>
						</div></td>
				</tr>
			</table>
		</div>
	</div>
	<div class="h_delete" style="display: none;">
		<h4>
			<input type="hidden" id="blogId" /> <a href="#" id="hidedelBlogDiv"
				onclick="hideDeleteDiv();"></a>删除日志
		</h4>
		<div class="h_delete_text">
			<p>
				你确定要删除该日记?<br />删除后无法恢复!
			</p>
			<div class="h_button fl" onclick="delBog(${blog.identifier});">
				<strong>删 除</strong>
			</div>
			<div class="h_button fl ml5" onclick="hideDeleteDiv();">
				<strong>取 消</strong>
			</div>
		</div>
	</div>